import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import ass.common.DBConnectionFactory;
import ass.common.ServiceLocatorException;

public class JDBCExample {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		String driver = "org.hsqldb.jdbcDriver";
		String url = "jdbc:hsqldb:I:/eclipse-jee-helios-SR2-win32/workspace/ass2COMP9321/MDB/HSQLDB";
		String username = "sa";
		String password = "";
		String sql = "insert into TBL_USERS(username,password) values (?, ?);";
		String tes11t;
		try {
			Class.forName(driver);
			
			DBConnectionFactory services = null;
			try {
				services = new DBConnectionFactory();
			} catch (ServiceLocatorException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			Connection conn = null;
			try {
				conn = services.createConnection();
			} catch (ServiceLocatorException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} 

//			Connection conn = DriverManager.getConnection(url, username,
//					password);
			PreparedStatement pstmt = conn.prepareStatement(sql);
			pstmt.setString(1, "Roy");
			pstmt.setString(2, "password");

			pstmt.executeUpdate();

			

			pstmt.close();
			conn.close();

		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		} 

	}
}